/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */
package cn.think.in.java;

import cn.think.in.java.common.NodeConfig;
import cn.think.in.java.entity.AentryParam;
import cn.think.in.java.entity.AentryResult;
import cn.think.in.java.entity.RvoteParam;
import cn.think.in.java.entity.RvoteResult;
import raft.client.ClientKVAck;
import raft.client.ClientKVReq;

/**
 * 一个RPC分布式网络节点的基本功能：
 * 处理请求投票 RPC.
 * 处理附加日志请求.
 * 处理客户端请求.
 * 转发给 leader 节点.
 */
public interface Node extends LifeCycle {

    /**
     设置节点信息
     */
    void setConfig(NodeConfig config);

    /**
     * 处理请求投票 RPC.
     */
    RvoteResult handlerRequestVote(RvoteParam param);

    /**
     * 处理附加日志请求.
     */
    AentryResult handlerAppendEntries(AentryParam param);

    /**
     * 处理客户端请求.
     */
    ClientKVAck handlerClientRequest(ClientKVReq request);

    /**
     * 重定向转发给 leader 节点.
     */
    ClientKVAck redirect(ClientKVReq request);

}
